package com.essence.grabiec104.grab;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.cache.annotation.EnableCaching;

@SpringBootApplication
@EnableCaching
public class GrabberApplication {
    private static Logger LOG = LoggerFactory.getLogger(GrabberApplication.class);

    public static void main(String[] args) {
        new SpringApplicationBuilder(GrabberApplication.class)
                .web(WebApplicationType.NONE)
                .listeners((ApplicationFailedEvent event) -> {
                    if (event.getException() instanceof IllegalStateException) {
                        LOG.error("Grab-IEC104-Grabber 启动失败...", event.getException());
                        System.exit(1);
                    }
                })
                .run(args);
        LOG.info("Grab-IEC104-Grabber 启动成功...");
    }
}
